package logic

import (
	"context"
	"goods_srv/elasticsearch"

	"goods_srv/goods"
	"goods_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type SearchListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewSearchListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SearchListLogic {
	return &SearchListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 搜素
func (l *SearchListLogic) SearchList(in *goods.SearchListRequest) (*goods.SearchListResponse, error) {
	// todo: add your logic here and delete this line

	goodsList := elasticsearch.SearchGoods(in.Keyword)

	return &goods.SearchListResponse{
		GoodsList: goodsList,
	}, nil
}
